//
//  AuthenResultInfoViewController.m
//  YTwallet
//
//  Created by ZhangLin on 2019/3/11.
//  Copyright © 2019年 hadrlog. All rights reserved.
//

#import "AuthenResultInfoViewController.h"
#import "AuthenResultInfoTableViewCell.h"
#import "AuthenResultInfoHeaderView.h"

@interface AuthenResultInfoViewController ()<UITableViewDataSource,UITableViewDelegate>

@property(nonatomic,strong)UITableView *tableView;
@property(nonatomic,strong)NSMutableArray *basicInfoArray;
@property(nonatomic,strong)NSMutableArray *swipeInfoArray;


@end

@implementation AuthenResultInfoViewController

-(NSMutableArray *)swipeInfoArray
{
    if (_swipeInfoArray == nil) {
        _swipeInfoArray = [NSMutableArray array];
    }
    return _swipeInfoArray;
}


-(NSMutableArray *)basicInfoArray
{
    if (_basicInfoArray == nil) {
        _basicInfoArray = [NSMutableArray array];
    }
    return _basicInfoArray;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"实名认证";
    self.view.backgroundColor = [UIColor colorWithRed:242 / 255.0 green:244 / 255.0 blue:246 / 255.0 alpha:1];
    //创建tableView
    [self createTableView];
    //添加已认证图片
    [self addImageView];
    
}
-(void)addImageView
{
    UIImageView *imv = [[UIImageView alloc] init];
    imv.image = [UIImage imageNamed:@"label_icon_yirenzheng"];
    imv.frame = CGRectMake(self.view.frame.size.width - 91, 0, 91, 91);
    [self.tableView addSubview:imv];
}
-(void)createTableView
{
    self.basicInfoArray = @[@"姓名",@"手机号",@"身份证号"].mutableCopy;
    self.swipeInfoArray = @[@"持卡人姓名",@"预留手机号",@"银行卡号",@"银行名称"].mutableCopy;
    
    
    self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, ETScreenW, ETScreenH - 64) style:(UITableViewStyleGrouped)];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    [self.view addSubview:self.tableView];
    self.tableView.separatorStyle = UITableViewCellSelectionStyleNone;
    [self.tableView registerClass:[AuthenResultInfoTableViewCell class] forCellReuseIdentifier:@"cell"];
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (section == 0) {
        return self.basicInfoArray.count;
    }else
    {
        return self.swipeInfoArray.count;
    }
    
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 2;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    AuthenResultInfoTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    if (indexPath.section == 0) {
        cell.titleLab.text = self.basicInfoArray[indexPath.row];
        
        if (indexPath.row == 0) {
            cell.tipsValueLab.text = self.accountName;
        }
        
        if (indexPath.row == 1) {
            cell.tipsValueLab.text = self.mobile;
        }
        
        if (indexPath.row == 2) {
            cell.tipsValueLab.text = self.crpIdenNumber;
        }
        
        
        
        
        //最后一个cell不显示分割线
        if (indexPath.row == self.basicInfoArray.count - 1) {
            cell.lineView.hidden = YES;
        }
    }else
    {
        cell.titleLab.text = self.swipeInfoArray[indexPath.row];
        if (indexPath.row == 0) {
            cell.tipsValueLab.text = self.accountName;
        }
        
        if (indexPath.row == 1) {
            cell.tipsValueLab.text = self.bankReservedMobile;
        }
        
        if (indexPath.row == 2) {
            cell.tipsValueLab.text = self.accountNo;
        }
        
        if (indexPath.row == 3) {
            cell.tipsValueLab.text = self.openBankName;
        }
        //最后一个cell不显示分割线
        if (indexPath.row == self.swipeInfoArray.count - 1) {
            cell.lineView.hidden = YES;
        }
    }
    
    return cell;
}

-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    AuthenResultInfoHeaderView *headerView = [[AuthenResultInfoHeaderView alloc] init];
    if (section == 0) {
        headerView.tipsLab.text = @"基本信息";
    }else{
        headerView.tipsLab.text = @"收款卡信息";
    }
    return headerView;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.section == 0 && indexPath.row == 3) {
        return 84;
    }else
    {
        return 44;
    }
}

-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 44;
}
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return 0.01f;
}
-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
    UIView *view=[[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 0.01)];
    view.backgroundColor = [UIColor clearColor];
    return view;
}


@end
